

let user: any = localStorage.getItem('userData')?JSON.parse(localStorage.getItem('userData') as string) : {}
const userStore = {
  namespaced: true,
  state: {
    data:{...user}
  },
  mutations: {
    //存储用户信息
    setUser(state: any, data: any) {
      state.data=data
      localStorage.setItem('userData',JSON.stringify(data))
    },

    //删除用户信息
    deleteUser(state:any) {
      state.data={}
      localStorage.removeItem('userData')
    }
  },
  actions: {}
}

export default userStore